use crate::{container::ChunkContainerWriter, constants::DefaultChunkPointer};

use super::{IndexStore, error::IndexResult};

pub static SAMPLING:fn(&IndexStore,&ChunkContainerWriter) -> IndexResult<()> = sampling_all;

pub fn sampling_all(index_store:&IndexStore,container:&ChunkContainerWriter) -> IndexResult<()> {
    for chunk in container.items() {
        index_store.insert_with_fp(chunk.fp(), &container.id())?;
        if chunk.layout().is_unique() {
            let cp = chunk.get_chunk_pointer::<DefaultChunkPointer>().unwrap();
            index_store.insert_with_sf(chunk.sf(),&cp)?;
        }
    }
    Ok(())
}